import { useEffect, useRef } from 'react'

import * as echarts from 'echarts';
const Myecharts = (props) => {
    let echartsBox = useRef(null)
    let myChart
    useEffect(() => {
        // 初始化echarts
        myChart = echarts.init(echartsBox.current);

        myChart.setOption(props.option)

    }, [props.option])
    // 监听浏览器窗口大小变化
    window.addEventListener("resize", function () {
        if (myChart) {
            myChart.resize();
        }
    })
    return (
        <div ref={echartsBox} style={{ width: '100%', height: '100%' }}>

        </div>
    )
}
export default Myecharts;